/**
 * 基于bootstrap的组件
 */
// CommonUtils.regNamespace("pack");
 pack = pack || {}
/**
 * 处理参数的类
 *
 * @param {}
 *            paramsType
 * @author zhaixq
 */
pack.params = function(paramsType) {
	this.parameterType = paramsType;
	this.displayContent = $("<div>").addClass("control-group").css("margin-bottom","4px").css("margin-left","4px");
	/**
	 * 获取显示的内容
	 * @param paramData 参数内容，如下：
	 * {
            "paramId": "301",
            "name": "速率属性值(VAL)",
            "paramsType": "P00",
            "itemSpecId": 12,
            "defaultValue": "8192",
            "valueDown": "",
            "valueUp": "",
            "optionValue": "",
            "actionId": "1010"
        },
	 */
	var scope = this;
	/**
	 * 渲染P00
	 */
	var _renderP00 = function(paramData, unitDiv) {
		var itemSpecId = paramData.itemSpecId;
		var paramId = paramData.parameterId;
		var paramsType = paramData.parameterType;
		var value = paramData.defaultValue;
		var actionId = paramData.actionItemId;
		scope.displayContent.attr("flag", "contentParam");
		scope.displayContent.attr("itemSpecId", itemSpecId);
		scope.displayContent.attr("paramId", paramId);
		scope.displayContent.attr("paramsType", paramsType);
		scope.displayContent.attr("value", value);
		scope.displayContent.attr("paramActionId", actionId);
		// 内容参数，速率属性值
		var controlLabelDiv = $("<div>").addClass("control-label").hide();

		controlLabelDiv.append(paramData.name);

		var controlsDiv = $("<div>").addClass("controls");

		scope.displayContent.append(controlLabelDiv);
		scope.displayContent.append(controlsDiv);
		scope.displayContent.hide();
		unitDiv.find("div[flag=contentDiv]").append(scope.displayContent);
	}
	/**
	 * 渲染S00
	 */
	var _renderS00 = function(paramData, unitDiv) {
		var paramId = paramData.parameterId;
		// 内容参数，速率属性值
		var controlLabelDiv = $("<div>").addClass("control-label");
		controlLabelDiv.css("margin","0 10px");
		controlLabelDiv.css("float","left");
		controlLabelDiv.css("width","auto");
		controlLabelDiv.css("text-align","left");
		
		var span = $("<span>").attr("title",paramData.name);
//		if(paramData.name.length > 13){
//			span.append(pack.utils.cutStr(paramData.name,10)+"...")
//		} else {
			span.append(paramData.name);
//		}
		controlLabelDiv.append(span);
		var controlsDiv = $("<div>").addClass("controls");
		controlsDiv.css("margin-left","10px");
		controlsDiv.css("float","left");
		var defaultValue = paramData.defaultValue;
		var optionValue = paramData.optionValue;
		var valueArray = optionValue.split("|");

		for(var i = 0 ; i < valueArray.length ; i ++){
			var val = valueArray[i];
			var radioLabel = $("<label>").addClass("radio inline");
			var radioInput = $("<input>").attr("type","radio").attr({"paramId":paramId,"name":"paramId_"+paramId}).val(val)
			radioLabel.append(radioInput);
			radioLabel.append(val);
			controlsDiv.append(radioLabel);
		}
		scope.displayContent.append(controlLabelDiv);
		scope.displayContent.append(controlsDiv);
		scope.displayContent.attr("flag", "packParams");
		scope.displayContent.attr("defaultValue", defaultValue);
		_addContentDivInUnitDiv(unitDiv,scope.displayContent);		

	}
	/**
	 * 渲染产品新装已有控制参数
	 * <ul>
	 * <li>找到新装、已有按钮、不需要按钮，增加标示</li>
	 * </ul>
	 */
	var _renderS01 = function(paramData, unitDiv) {
		var paramId = paramData.parameterId;
		var optionValue = paramData.optionValue;
		var defaultValue = paramData.defaultValue;
		var values = optionValue.split("|");
		// TODO:检查数据

		var newRadio = unitDiv.find("input[type=radio][flag='Y']");
		var usedRadio = unitDiv.find("input[type=radio][flag='N']");
		var noUsedRadio = unitDiv.find("input[type=radio][flag='D']");
		//TODO:值写死了，'Y','N'
		if(newRadio && newRadio.length == 1){
			newRadio.val("Y").attr({"paramId":paramId});
		}
		if(usedRadio && usedRadio.length == 1){
			usedRadio.val("N").attr({"paramId":paramId});
		}
		if(noUsedRadio && noUsedRadio.length == 1){
			noUsedRadio.val("D").attr({"paramId":paramId});
		}
		scope.displayContent = null;
	}

	/**
	 * 多选多
	 */
	var _renderS02 = function(paramData, unitDiv) {
		var paramId = paramData.parameterId;
		// 下限
		var down = paramData.valueDownlimit;
		// 上限
		var up = paramData.valueUplimit;
		var name = paramData.name;
		var optionValue = paramData.optionValue;
		var defaultValue = paramData.defaultValue;

		var valueArray = optionValue.split("|");

		var controlLabelDiv = $("<div>").addClass("control-label")
		controlLabelDiv.css("margin","0 10px");
		controlLabelDiv.css("float","left");
		controlLabelDiv.css("width","auto");
		controlLabelDiv.css("text-align","left");
		var span = $("<span>").attr("title",name);
//		if(name.length > 13){
//			span.append(pack.utils.cutStr(name,10)+"...");
//		} else {
			span.append(name);
//		}
		controlLabelDiv.append(span);
		
		var controlsDiv = $("<div>").addClass("controls");
		controlsDiv.css("margin-left","10px");
		controlsDiv.css("float","left");
		for(var i = 0 ; i < valueArray.length ; i ++){
			var val = valueArray[i];
			var radioLabel = $("<label>").addClass("checkbox inline");
			var radioInput = $("<input>").attr("type","checkbox").attr({"paramId":paramId,"name":"paramId_"+paramId}).val(val);
			radioLabel.append(radioInput);
			radioLabel.append(val);
			controlsDiv.append(radioLabel);
		}
		scope.displayContent.append(controlLabelDiv);
		scope.displayContent.append(controlsDiv);

		scope.displayContent.attr("flag", "packParams");
		scope.displayContent.attr("parameterType", scope.parameterType);
		scope.displayContent.attr("defaultValue", defaultValue);
		scope.displayContent.attr("up", up);
		scope.displayContent.attr("down", down);

		_addContentDivInUnitDiv(unitDiv,scope.displayContent);	

	}
	/**
	 * 渲染S03(预后参数类型)
	 */
	var _renderS03 = function(paramData, unitDiv) {
		var paramId = paramData.parameterId;
		var actionItemId = paramData.actionItemId;
		//
		var controlLabelDiv = $("<div>").addClass("control-label");
		controlLabelDiv.append(paramData.name);
		
		var spanDiv = $("<div>").css("width","auto");
		spanDiv.css("float","left");
		var controlsDiv = $("<div>").addClass("controls");
		var defaultValue = paramData.defaultValue;
		var optionValue = paramData.optionValue;
		var valueArray = optionValue.split("|");

		for (var i = 0; i < valueArray.length; i++) {
			var val = valueArray[i];
			var valName = '';
			if (val == '1') {
				valName = '后付费';
			} else {
				valName = '预付费';
			}
			var radioLabel = $("<label>").addClass("radio inline").css("padding-top","0px").css("margin-left","5px");
			var radioInput = $("<input>").attr("type","radio").attr({"paramId":paramId,"name":"paramId_"+paramId}).val(val)
			radioLabel.append(radioInput);
			radioLabel.append(valName);
			spanDiv.append(radioLabel);
		}
//		scope.displayContent.append(controlLabelDiv);
//		scope.displayContent.append(controlsDiv);
		spanDiv.attr("flag","feeTypes");
		spanDiv.attr("paramActionId",actionItemId);
		spanDiv.attr("defaultValue",defaultValue);
		spanDiv.attr("paramsType",scope.parameterType);
		spanDiv.attr("paramId",paramId);
		unitDiv.find("div[actionId="+actionItemId+"]").find(".controls").append(spanDiv);
	}
	
	/**
	 * 在unitDiv中增加当前参数div，专门为S00,S02参数调用
	 */
	var _addContentDivInUnitDiv  = function(unitDiv,contentDiv){
		var hr = $("<hr>").css("margin","1px 0 0 0");
		var contentDiv = unitDiv.find("div[flag=contentDiv]");
		var partInObjectDiv = unitDiv.find("div[flag=partInObject]");
		var hasPartInObjectFlag = true;
		if(partInObjectDiv.length == 0){
			hasPartInObjectFlag = false;
		}
		if(contentDiv.find("hr").length == 1){
			if(contentDiv.find("div").length > 0){
				contentDiv.find("div").eq(0).before(hr);
			} else {
				contentDiv.append(hr);
			}
		} else if(contentDiv.find("hr").length == 2 && hasPartInObjectFlag){
			contentDiv.find("hr:last").after(hr);
		}
		unitDiv.find("hr:last").before(scope.displayContent);	
	}
	this.getDisplaycontent = function(paramData, unitDiv) {
		if (scope.parameterType == 'P00') {
			// 内容参数不需要处理
			_renderP00(paramData, unitDiv);
		} else if (scope.parameterType == 'S00') {
			// 控参，离散值
			_renderS00(paramData, unitDiv);
		} else if (scope.parameterType == 'S01') {
			// 产品新装已有
			_renderS01(paramData, unitDiv);
		} else if (scope.parameterType == 'S02') {
			// 多选多
			_renderS02(paramData, unitDiv);
		} else if (scope.parameterType == 'S03') {
			// 预、后付费
			_renderS03(paramData, unitDiv);
		} else if(("|" + pack.consts.CONST_EXTRAL_PARAM_TYPES.join("|") + "|").indexOf("|"+scope.parameterType+"|") != -1){
			//如果是额外需要处理的参数类型，则放置在全局变量中的extralParams节点下
			pack.gPackInfo.extralParams.push(paramData);
		}
		else{
			alert("当前参数类型【"+scope.parameterType+"】不支持！~~");
			return;
		}
		return scope.displayContent;
	};
}
/**
 * 打包动作处理类
 *
 * @author zhaixq
 */
pack.actions = function() {

	var _getContentDiv = function(actionData) {
		var actionTypeCd = actionData.actionTypeCd;
		var effectObjNumber = actionData.effectobjNumber;
		var partObjNumber = actionData.partobjNumber;
		var roleCd = actionData.roleCd;

				return $("<div>").addClass("control-group").css("margin-bottom","4px")
						.attr("actionTypeCd",actionTypeCd)
						.attr("effectObjNumber",effectObjNumber)
						.attr("partObjNumber",partObjNumber)
						.attr("roleCd",roleCd);

	}
	var _getLabelDiv = function() {
		return $("<div>").addClass("control-label").css("width", "25px");
	}
	var _getControlsDiv = function(){
		return $("<div>").addClass("controls").css("margin-top","6px").css("margin-left",'4px')
						 .css("float","left")
						 .css("width","90%")
						 .css("height","auto");
	}
	var _getActionDescSpan = function(actionDesc){
		return $("<span>").css("float","left").attr("title",actionDesc);
	}
	/**
	 * set label Div
	 */
	var _setLabelDiv = function(labelDiv, isMust) {
		//销售品（描述）
		if(isMust == 'Y'){
			var okImg = $("<img>").attr("src","../resources/images/ok.png").attr({"width":16,height:16}).attr("flag","true");
			labelDiv.append(okImg);
		} else {
			var div = $("<div>").css({"width":16,height:16}).css("float","right");
			var checkBoxLabel = $("<label>").addClass("checkbox");
			var checkBoxInput = $("<input>").attr("type","checkbox").attr("checked",false);
			checkBoxLabel.append(checkBoxInput);
			div.append(checkBoxLabel);
			labelDiv.append(div);
		}
	};
	/**
	 * 渲染1
	 */
	var _render1 = function(actionData, effectObj) {
		// obtain action info
		var partObjNumber = actionData.partobjNumber;
		var effectObjNumber = actionData.effectobjNumber;
		var actionDesc = actionData.description;
		var isVisible = actionData.isVisible;
		var isMust = actionData.isMust;
		var actionId = actionData.actionItemId;
		// obtain effectObj info
		var effectObjType = effectObj.objType;
		var effectObjId = effectObj.objId;

		// render div
		var contentDiv = _getContentDiv(actionData);
		if (isVisible == 'N') {
			contentDiv.hide();
		}
		contentDiv.attr("actionId", actionId);
		var labelDiv = _getLabelDiv();
		var controlsDiv = _getControlsDiv();
		//set label Div
		_setLabelDiv(labelDiv,isMust);
		//set controls div
		var actionDescSpan = _getActionDescSpan(actionDesc);
//		if(actionDesc.length >= 31){
//			actionDescSpan.append(pack.utils.cutStr(actionDesc,28)+"...")
//		} else {
			actionDescSpan.append(actionDesc);
//		}
		controlsDiv.append(actionDescSpan);
		contentDiv.append(labelDiv);
		contentDiv.append(controlsDiv);
		return contentDiv;
	};
	/**
	 * 渲染100（订购）
	 */
	var _render100 = function(actionData, effectObj) {
		// obtain action info
		var partObjNumber = actionData.partobjNumber;
		var effectObjNumber = actionData.effectobjNumber;
		var actionDesc = actionData.description;
		var isVisible = actionData.isVisible;
		var isMust = actionData.isMust;
		var actionId = actionData.actionItemId;
		// obtain effectObj info
		var effectObjType = effectObj.objType;
		var effectObjId = effectObj.objId;

		// render div
		var contentDiv = _getContentDiv(actionData);
		contentDiv.attr("actionId", actionId);
		if (isVisible == 'N') {
			contentDiv.hide();
		}
		var labelDiv = _getLabelDiv();
		var controlsDiv = _getControlsDiv();
		
		_setLabelDiv(labelDiv,isMust);
		//订购
		if(effectObjType == 7){
			var actionDescSpan = _getActionDescSpan(actionDesc);
//			if(actionDesc.length >= 31){
//				actionDescSpan.append(pack.utils.cutStr(actionDesc,28)+"...")
//			} else {
				actionDescSpan.append(actionDesc);
//			}
			controlsDiv.append(actionDescSpan);
		} else if(effectObjType == 24){
		}
		contentDiv.append(labelDiv);
		contentDiv.append(controlsDiv);
		return contentDiv;
	};

	/**
	 * 渲染101（加入）
	 */
	var _render101 = function(actionData, effectObj) {
		// obtain action info
		var partObjNumber = actionData.partobjNumber;
		var effectObjNumber = actionData.effectobjNumber;
		var actionDesc = actionData.description;
		var isVisible = actionData.isVisible;
		var isMust = actionData.isMust;
		var actionId = actionData.actionItemId;
		// obtain effectObj info
		var effectObjType = effectObj.objType;
		var effectObjId = effectObj.objId;

		// render div
		var contentDiv = _getContentDiv(actionData);
		if (isVisible == 'N') {
			contentDiv.hide();
		}
		contentDiv.attr("actionId", actionId);
		var labelDiv = _getLabelDiv();
		var controlsDiv = _getControlsDiv();
		//set label Div
		_setLabelDiv(labelDiv,isMust);
		//set controls div
		var actionDescSpan = _getActionDescSpan(actionDesc);
//		if(actionDesc.length >= 31){
//			actionDescSpan.append(pack.utils.cutStr(actionDesc,28)+"...")
//		} else {
			actionDescSpan.append(actionDesc);
//		}
		controlsDiv.append(actionDescSpan);
		contentDiv.append(labelDiv);
		contentDiv.append(controlsDiv);
		return contentDiv;
	};

	/**
	 * 渲染201
	 */
	var _render201 = function(actionData, effectObj) {
		// obtain action info
		var partObjNumber = actionData.partobjNumber;
		var effectObjNumber = actionData.effectobjNumber;
		var actionDesc = actionData.description;
		var isVisible = actionData.isVisible;
		var isMust = actionData.isMust;
		var actionId = actionData.actionItemId;

		// obtain effectObj info
		var effectObjType = effectObj.objType;
		var effectObjId = effectObj.objId;

		// render div
		var contentDiv = _getContentDiv(actionData);
		if (isVisible == 'N') {
			contentDiv.hide();
		}
		contentDiv.attr("actionId", actionId);
		var labelDiv = _getLabelDiv();
		var controlsDiv = _getControlsDiv();
		//set label Div
		_setLabelDiv(labelDiv,isMust);
		//set controls div
		var actionDescSpan = _getActionDescSpan(actionDesc);
//		if(actionDesc.length >= 31){
//			actionDescSpan.append(pack.utils.cutStr(actionDesc,28)+"...")
//		} else {
			actionDescSpan.append(actionDesc);
//		}
		controlsDiv.append(actionDescSpan);
		contentDiv.append(labelDiv);
		contentDiv.append(controlsDiv);
		return contentDiv;
	}
	/**
	 * 渲染
	 */
	var _getDisplayContent = function(actionData, effectObj) {
		// 获取action上的值
		var actionTypeCd = actionData.actionTypeCd;
		// 目标对象类型
		var effectObjType = effectObj.objType;

		var contentDiv = null;
		// 显示表示
		switch (parseInt(actionTypeCd)) {
			case 1 :
				contentDiv = _render1(actionData, effectObj);
				break;
			case 100 :
				contentDiv = _render100(actionData, effectObj);
				break;
			case 101 :
				// 加入
				// 描述
				contentDiv = _render101(actionData, effectObj);
				break;
			case 201 :
				// 设置属性
				// 下拉菜单
				contentDiv = _render201(actionData, effectObj);
				break;
			default :
				alert("当前动作类型【" + actionTypeCd + "】不支持！~~");
				break;
		}
		return contentDiv;
	}
	return {
		getDisplayContent : _getDisplayContent
	}
}();
/**
 * 促销处理模板
 */
pack.template = function() {
	/**
	 * 以产品为单位模板
	 */
	var _salesTotalTemplate = "<form class=\"form-signin form-horizontal\">                         "
			+ "  <h3 class=\"form-signin-heading\"><span class=\"badge badge-info\">1</span></h3> "
			+ "  <hr/>                                                                         	"
			+ " 	<hr/>                                                                       	 	"
			+ " 	<hr/>                                                                       	 	"
			+ "</form>    ";
	/**
	 * 某一行模板
	 */
	var _rowTemplate = "<div class=\"control-group\">                                                       "
			+ "	<label class=\"control-label\"><strong></strong></label>	                         "
			+ "	<div class=\"controls\">                                                           "
			+ "	</div>                                                                             "
			+ "</div>                                                                              ";

	/**
	 *
	 */
	var _rowTemplateForMore = "";

	/**
	 * 选择新装或者已有模板
	 */
	var _chooseNewOrOldTemplate = "<div class=\"span1\" style='margin-left:0px;'>                                                                 "
			+ "	<label class=\"radio\" >                                                              "
			+ "		<input type=\"radio\" name=\"optionsRadios\"  flag='Y'>                         "
			+ "			新装                                                                             "
			+ "		</input>                                                                           "
			+ "	</label>                                                                             "
			+ "</div>"
			+ "<div class=\"span1\" style='margin-left:0px;'>                                                                 "
			+ "	<label class=\"radio\">                                                              "
			+ "		<input type=\"radio\" name=\"optionsRadios\" flag='N'>                          "
			+ "			已有                                                                         "
			+ "		</input>                                                                           "
			+ "	</label>                                                                             "
			+ "</div>"
			+ "<div class=\"span2\" style='margin-left:0px;width:auto;'>                                                                 "
			+ "</div>"
			+ "<div class='span2' style='display:none;margin-left:2px;width:70px;height:23px;' >                                                                   "
			+ "	<button type='button' class='btn' id='searchOther' style='margin-bottom:5px;padding:3px 7px;'>查询其他</button> "
			+ "</div>"
			+ "<div class='span2' style='margin-left:2px;width:70px;'>                                                                   "
			+ "	<label class=\"radio\">                                                              "
			+ "		<input type='radio' name ='optionsRadios' flag = 'D'>不需要</input>               "
			+ "	</label>                                                                             "
			+ "</div>";
	/**
	 * 根据状态标示获取新老用户选择div
	 */
	var _getNewOrOldDiv = function(flag) {
		var newOrOldTemplate = _chooseNewOrOldTemplate;
		var _template = null;
		try {
			_template = $("<div>").append(newOrOldTemplate);
		} catch (e) {
			alert(e);
		}
		if (flag.indexOf("Y") == -1) {
			var newRaido = _template.find("input[flag='Y']");
			newRaido.parent().parent().remove();
		}
		if (flag.indexOf("N") == -1) {
			var usedRadio = _template.find("input[flag='N']");
			var usedDiv = usedRadio.parent().parent();
			usedDiv.next().next().remove();
			usedDiv.next().remove();
			usedDiv.remove();
		}
		if (flag.indexOf("D") == -1) {
			var noRadio = _template.find("input[flag=D]");
			noRadio.parent().parent().remove();
		}
		return _template.children();
	};
	/**
	 * 获取整个显示模板
	 */
	var _getSalesTotalTemplate = function() {
		return _salesTotalTemplate;
	};
	/**
	 * 获取行模板
	 */
	var _getRowTemplate = function() {
		return _rowTemplate;
	}
	return {
		getSalesTotalTemplate : _getSalesTotalTemplate,
		getRowTemplate : _getRowTemplate,
		getNewOrOldDiv : _getNewOrOldDiv
	}
}();
pack.dataProcess = function() {
	var content = null;
	var oldData = null;
	var unitDivs = null;
	var packObjects = [];
	var actions = [];
	var params = [];
	var feeType = '';
	/**
	 * 收集数据
	 */
	var _collectParams = function() {
		var paramDivs = $(content).find("div[flag=contentParam]");
		if (paramDivs) {
			$.each(paramDivs, function(i, o) {
						var itemSpecId = $(o).attr("itemSpecId");
						var paramId = $(o).attr("paramId");
						var paramsType = $(o).attr("paramsType");
						var value = $(o).attr("value");
						var actionId = $(o).attr("paramActionId");
						params.push({
									itemSpecId : itemSpecId,
									paramId : paramId,
									paramsType : paramsType,
									value : value,
									actionId : actionId
								})
					});
		}
		var feeTypeDivs = $(content).find("div[flag=feeTypes]");
		$.each(feeTypeDivs, function(i, o) {
					var paramId = $(o).attr("paramId");
					var paramsType = $(o).attr("paramsType");
					var value = $(o).find("input[type=radio]:checked").val();
					var actionId = $(o).attr("paramActionId");
					params.push({
								itemSpecId : '',
								paramId : paramId,
								paramsType : paramsType,
								value : value,
								actionId : actionId
							})
				});
	}
	/**
	 * 收集包对象
	 */
	var _collectPackObject = function() {
		var dealFlag = true;
		var oldPackObjects = oldData.packObjects;
		// 获取原来的包对象
		// 从原有数据中复制客户、销售品包对象
		$.each(oldPackObjects, function(i, o) {
					var objType = o.objType;
					if (objType == 1 || objType == 7) {
						var isNew = o.isNew;
						var objId = o.objId;
						var objType = o.objType;
						var name = o.objectName;
						var objNumber = o.objectNumber;
						packObjects.push({
									isNew : isNew,
									objId : objId,
									objType : objType,
									name : name,
									objNumber : objNumber
								})
					}
				});
		// 收集产品、收集标签
		$.each(unitDivs, function(i, o) {
					var partyInObjectDiv = $(o).find("div[flag=partInObject]");
					if(partyInObjectDiv.length > 0){
						var objId  = $(partyInObjectDiv).attr("objId");
						var objType = $(partyInObjectDiv).attr("objType");
						var objNumber = $(partyInObjectDiv).attr("objNumber");
						var isNew = '';
						var objectName = $(partyInObjectDiv).attr("name");
						var checkedRadio = $(partyInObjectDiv)
								.find("input[type=radio]:checked");
						var objInstId = null;
						var accessNumber = null;
						if (checkedRadio.attr('flag') == 'N') {
							if ($(partyInObjectDiv).find(".btn-group").length == 0) {
								alert("【" + objectName + "】未选择号码，请纳入已有号码！");
								dealFlag = false;
								return false;
							}
							var valueButton = $(partyInObjectDiv)
									.find(".btn-group").find("button:eq(0)");
							objInstId = valueButton.attr("prodId");
							accessNumber = valueButton.html();
							isNew = 'N';
						} else if (checkedRadio.attr('flag') == 'Y') {
							isNew = 'Y';
						}
						if (objType != 1) {
							packObjects.push({
										isNew : isNew,
										objId : objId,
										objType : objType,
										name : objectName,
										objNumber : objNumber,
										objInstId : objInstId,
										accessNumber : accessNumber
									})
						}
					}
				})
		if (!dealFlag) {
			return dealFlag;
		}
		// 收集标签
		var labelEffectObjs = content.find("div[flag=labelEffectObj]");
		$.each(labelEffectObjs, function(i, o) {
					var valueButton = $(o).find(".btn-group").find("button:eq(0)");
					var objId = valueButton.attr("val");
					var objType = 7;
					var objNumber = $(o).attr("objNumber");
					var isNew = $(o).attr("isNew");
					var name = valueButton.html();
					if (objType != 1) {
						packObjects.push({
									isNew : isNew,
									objId : objId,
									objType : objType,
									name : name,
									objNumber : objNumber
								})
					}
				});
		return dealFlag;
	}

	/**
	 * 收集动作
	 */
	var _collectActions = function() {
		$.each(unitDivs, function(i, o) {
			var actionDivs = $(o).find("div[actionId]");
			if (actionDivs) {
				$.each(actionDivs, function(j, oo) {
					var checkboxInput = $(oo).find("input[type=checkbox]");
					var imgInput = $(oo).find("img");
					if((checkboxInput.length == 0 && imgInput.length == 1 && (imgInput.attr("flag") == "true"))|| 
						(checkboxInput.length == 1 && checkboxInput[0].checked)){
						var actionId = $(oo).attr("actionId");
						var roleCd = $(oo).attr("roleCd");
						var partObjNumber = $(oo).attr("partObjNumber");
						var actionTypeCd = $(oo).attr("actionTypeCd");
						var effectObjNumber = $(oo).attr("effectObjNumber");

						actions.push({
									actionId : actionId,
									roleCd : roleCd,
									partObjNumber : partObjNumber,
									actionTypeCd : actionTypeCd,
									effectObjNumber : effectObjNumber
								})
					}
				});
			}
		});
	}
	/**
	 * 过滤内容
	 */
	var _filterContent = function() {
		var preUnitDivs = $(content).find(".packContanierUnit");
		$.each(preUnitDivs, function(i, o) {
					var partInObjectDiv = $(o).find("div[flag=partInObject]");
					var noNeedRadio = partInObjectDiv.find("input[type=radio][flag=D]:checked");
					if(!noNeedRadio || noNeedRadio.length == 1){
						$(o).remove();
					}

				});
	}
	/**
	 * 收集数据
	 */
	var _collectData = function(_content, _oldData) {
		content = _content.clone();
		oldData = _oldData;
		packObjects = [];
		actions = [];
		params = [];
		feeType = '';
		// 过滤content
		_filterContent();
		unitDivs = $(content).find(".packContanierUnit");
		_collectParams();
		if (!_collectPackObject()) {
			return false;
		}
		_collectActions();
		// 设置全局
		pack.gPackInfo.packObjects = packObjects;
		pack.gPackInfo.actions = actions;
		pack.gPackInfo.params = params;

		// 设置值
		pack.gPackInfo.packParams =  oldData.packParams;
		pack.gPackInfo.paramMapRelas = oldData.paramMapRelas;
		pack.gPackInfo.areaId = pack.gPackInfo.baseInfo.areaId;
		pack.gPackInfo.custId = pack.gPackInfo.baseInfo.partyId;
		pack.gPackInfo.channelId = pack.gPackInfo.baseInfo.channelId;
		pack.gPackInfo.staffId = pack.gPackInfo.baseInfo.staffId;
		pack.gPackInfo.feeType = feeType;
		return true;
	}
	return {
		collectData : _collectData
	}
}();

/**
 * pack容器
 */
pack.packContainer = function(_cfg) {
	this.data = [];
	this.content = $("<div>").addClass("container").css("width","100%").css("padding-left","20px");
	this.url = null;
	if (_cfg && typeof _cfg == 'object') {
		$.extend(this, _cfg);
	}
	var scope = this;
	/**
	 * 获取所有参与对象
	 */
	var _getAllPartInObject = function() {
		var partInObjectArray = [];
		for (var i = 0; i < scope.data.packObjects.length; i++) {
			var pObj = scope.data.packObjects[i];
			if (pObj.objType == 1 || pObj.objType == 2) {
				partInObjectArray.push(pObj);
			}
		}
		return partInObjectArray;
	}
	/**
	 * 获得所有服务类参与对象
	 */
	var _getAllServObject = function() {
		var partInObjectArray = [];
		for (var i = 0; i < scope.data.packObjects.length; i++) {
			var pObj = scope.data.packObjects[i];
			if (pObj.objType == 4) {
				partInObjectArray.push(pObj);
			}
		}
		return partInObjectArray;
	};
	/**
	 * 为选择已有按钮注册事件
	 */
	var _bindClickEventForUsedProd = function(partInObject, isNewDiv) {
		var isNew = partInObject.isNew;
		var objId = partInObject.objId;

		var radioDiv = $(isNewDiv).find("input[type=radio][flag='N']");
		var otherRadioDiv = $(isNewDiv).find("input[type=radio][flag!='N']");
		if (radioDiv.length == 0) {
			return;
		}
		var params = {
			partyId : pack.gPackInfo.baseInfo.partyId,
			prodSpecId : objId
		}

		radioDiv.bind("click", function() {
			if (radioDiv.parent().parent().next().find(".btn-group").length == 0) {
				var prodList = pack.Index.search.queryProdInstByCond(params);
				if (!prodList || prodList.length == 0) {
					radioDiv.parent().parent().next().css("color","black").css("margin-bottom","5px").html("没有产品已有号码！");
				} else {
					var cb = new bootstrap.components.ComboBox();
					$.each(prodList, function(i, o) {
								var accessNumber = o.accessNumber;
								var areaId = o.areaId;
								var prodId = o.prodId;
								var name = o.name;
								cb.addData({
											name : accessNumber,
											value : accessNumber,
											attrs : {
												prodId : prodId
											}
										})
							})
					cb.show(radioDiv.parent().parent().next());
				}
				radioDiv.parent().parent().next().next().find("button").bind("click",function(){
					var accNbrSearchPanel = new bootstrap.components.AccNbrSearchPanel({
						"objNumber": partInObject.objectNumber ,
						'objId' : partInObject.objId,
						'objectName' : partInObject.objectName,
						"domId" : "#searchOtherWin"
					});
					accNbrSearchPanel.show();
				});
				radioDiv.parent().parent().next().next().show();
			}

		});
		otherRadioDiv.bind("click", function() {
					radioDiv.parent().parent().next().empty();
					radioDiv.parent().parent().next().next().hide();
				});

	}
	/**
	 * 渲染参与对象
	 */
	var _showPartInObject = function(unitDiv, partInObject, index) {
		// obtain value
		var objId = partInObject.objId;
		var objType = partInObject.objType;
		var objNumber = partInObject.objectNumber;
		var isNew = partInObject.isNew;
		var name = partInObject.objectName;
		//default value
		var defaultValue = partInObject.defaultValue;
		//
		var rowFluidDiv = $("<div>")
							.css("height","40px")
							.css("background","url(../resources/images/pack/packParamBg.png)no-repeat")
							.css("padding-top","8px")
							.css("margin-left","0px");
		//
		var objTitleDiv = $("<div>").addClass("span2")
							.css("width",'auto').css("margin-left","22px").css("color","#CC6600")
							.attr("title",name);
		//渲染
		var h4 = $("<h3>");
		h4.append(name);
		objTitleDiv.append(h4);
		rowFluidDiv.append(objTitleDiv);
		//增加分隔栏
		unitDiv.find(".pDiv").before(rowFluidDiv);
		_showHr(unitDiv.find(".contentDiv"));
		// 渲染新装已有、可无
		if (partInObject.objType && partInObject.objType != 1) {
			// 增加分隔符
			// _showHr(unitDiv);
			// 渲染参与对象
			// 1.2 选择产品新装或者已有信息
			var isNewDiv = $(pack.template.getNewOrOldDiv(partInObject.isNew));
			// 修改radio的name
			isNewDiv.find("input[type=radio]").attr("name","optionsRadios_"+partInObject.objectNumber);
			//给已有radio注册事件
//			_bindClickEventForUsedProd(partInObject, isNewDiv);
			var partInObjectDiv = $("<div>").addClass("row");
			//css
			partInObjectDiv.css("margin-left","15px");
			partInObjectDiv.css("margin-top","5px");
			//attr
			partInObjectDiv.attr("flag","partInObject");
			partInObjectDiv.attr("objId",objId);
			partInObjectDiv.attr("objType",objType);
			partInObjectDiv.attr("objNumber",objNumber);
			partInObjectDiv.attr("isNew",isNew);
			partInObjectDiv.attr("name",name);
			partInObjectDiv.attr("defaultValue",defaultValue);
			partInObjectDiv.append(isNewDiv);
			unitDiv.find(".contentDiv").append(partInObjectDiv);
			_showHr(unitDiv.find(".contentDiv"));
		}
	

	}
	/**
	 * 渲染动作
	 */
	var _showAction = function(unitDiv, action) {
		var effectObjNumber = action.effectobjNumber;
		var effectObj = null;
		// 获取目标对象
		for (var i = 0; i < scope.data.packObjects.length; i++) {
			var pObj = scope.data.packObjects[i];
			var objNumber = pObj.objectNumber;
			if (objNumber == effectObjNumber) {
				effectObj = pObj;
				break;
			}
		}
		if (!effectObj) {
			alert("包配置问题，未找到目标对象" + effectObjNumber + "，请联系系统管理员！");
			return false;
		}
		// call special class to deal with action
		var div = pack.actions.getDisplayContent(action, effectObj);
		unitDiv.find("div[flag=contentDiv]").append(div);
	}

	/**
	 * 显示参数（包括控制参数+内容参数）
	 */
	var _showParams = function(unitDiv,action){
		var params = action.actionItemParameterList;
		if(params){
			for(var i = 0; i < params.length ; i ++){
				var param = params[i];
				var paramsType = param.parameterType;
				var p = new pack.params(paramsType);
				p.getDisplaycontent(param,unitDiv);
			}
		}
	}
	var _showHr = function(unitDiv) {
		unitDiv.append($("<hr>").css("margin", "5px 0 0 0"));
	}
	/**
	 * 支持成员为多个服务的销售品包
	 */
	var _showForServPackage = function(servObjectArray) {

	}
	/**
	 * <ul>
	 * 渲染
	 * <li>1.获取所有参与对象</li>
	 * <li>2.渲染参与对象</li>
	 * <li>3.渲染动作</li>
	 * <li>4.渲染控制参数</li>
	 * <li>5.渲染内容参数</li>
	 * </ul>
	 */
	var _show = function(partInObjectArray) {
		for (var i = 0; i < partInObjectArray.length; i++) {
			var partInObject = partInObjectArray[i];
			var unitDiv = $("<div>").addClass("packContanierUnit form-horizontal")
			var pDiv = $("<div>").addClass("pDiv");
			var div = $("<div>").addClass("contentDiv").attr("flag","contentDiv");
			pDiv.append(div);
			//增加
			unitDiv.append(pDiv);
			//渲染参与对象
			_showPartInObject(unitDiv,partInObject,i);
			for (var j = 0; j < scope.data.actions.length; j++) {
				var action = scope.data.actions[j];
				var partObjNumber = action.partobjNumber;
				if (partInObject.objectNumber == partObjNumber) {
					// 渲染动作
					_showAction(unitDiv, action);
					// 渲染参数
					_showParams(unitDiv, action);
				}
			}
			scope.content.append(unitDiv);
		}
	}
	/**
	 * 为不需要的按钮注册事件
	 */
	var _regesiterEventsForNoNeedRadio = function() {
		var unitDivs = scope.content.find(".packContanierUnit");
		$.each(unitDivs, function(i, o) {
					var radioInput = $(o).find("input[type=radio][flag=D]");
					if (radioInput && radioInput.length == 1) {
						// 给不需要的按钮注册事件
						$(radioInput).bind("click", function() {
									($(o).find(".control-group")).hide('1000');
								});
						var otherRadioInput = $(o).find("input[type=radio][flag!=D]");
						otherRadioInput.bind("click", function() {
									($(o).find(".control-group")).show('1000');
								});
					}
				});
	}
	/**
	 * 改变控制参数注册事件协议
	 * 将原有协议转换成一下格式
	 *[
    {
        "1017": {
            "actionItemId": 1017,
            "relaType": "Y",
            "parameterIds": [
                94
            ],
            "controls": [
                {
                    "parameterId": "94",
                    "value": "WLAN国际漫游"
                }
            ]
        }
    }
]
	 */
	var _changeParamActionRelas = function(oldParamActionRelas) {
		var newParamActionRelas = {};
		$.each(oldParamActionRelas, function(i, o) {
			// obtain values
			var actionItemId = o.actionItemId;
			var relaType = o.relaType;
			var parameterId = o.parameterId;
			var value = o.value;
			var existsFlag = false;
			// 判断是否存在
			$.each(newParamActionRelas, function(key, value) {
						if (key == actionItemId) {
							if (newParamActionRelas[key].relaType == relaType) {
								existsFlag = true;
							}
						}
					});
			if (existsFlag) {
				var tempActionRela = newParamActionRelas[actionItemId];
				var params = tempActionRela.parameterIds;
				var controls = tempActionRela.controls;
				if(("|"+params.join("|") + "|").indexOf("|"+parameterId+"|") == -1){
					params.push(parameterId);
					controls.push({
						parameterId : parameterId,
						value :　value
					});
				} else {
					var controlExists = false;
					$.each(controls, function(ii, oo) {
						if (oo.parameterId == parameterId && oo.value == value) {
							controlExists = true;
						}
					});
					if (!controlExists) {
						params.push(parameterId);
						controls.push({
							parameterId : parameterId,
							value :　value
						});
					}
				}
				// 判断
			} else {
				var tempActionRela = {
					actionId :　actionItemId,
					relaType : relaType,
					parameterIds : [parameterId],
					controls : [{
						parameterId : parameterId,
						value :　value
					}]
				}
				newParamActionRelas[actionItemId] = tempActionRela;
			}
		});
		return newParamActionRelas;
	}
	/**
	 * 为控制参数注册事件
	 * scope.data.controls 
	 * 示例："8112_C": {
            "actionId": 8112,
            "relaType": "C",
            "parameterIds": [
                3106,
                3104
            ],
            "paramterRelas": [
                [
                    {
                        "actionItemId": 8112,
                        "grpId": 1000026,
                        "parameterId": 3104,
                        "relaType": "C",
                        "value": "免初装费"
                    }
                ],
                [
                    {
                        "actionItemId": 8112,
                        "grpId": 1000025,
                        "parameterId": 3104,
                        "relaType": "C",
                        "value": "免移机费"
                    },
                    {
                        "actionItemId": 8112,
                        "grpId": 1000025,
                        "parameterId": 3106,
                        "relaType": "C",
                        "value": "Y"
                    }
                ]
            ]
        }
	 */
	var _regesiterEventsForControlParam = function(){
//		var oldParamActionRelas = scope.data.paramActionRelas;
//		var paramActionRelas= _changeParamActionRelas(oldParamActionRelas);
		var paramActionRelas = scope.data.controls;
		$.each(paramActionRelas,function(key,p){
			//obtain values
			var paramActionRela = paramActionRelas[key];
			var actionId = paramActionRela.actionId;
			var relaType = paramActionRela.relaType;
			var parameterIds = paramActionRela.parameterIds;
			var controls = paramActionRela.paramterRelas;
			//
			var noImg = $("<img>").attr("src","../resources/images/error.png").attr({"width":16,height:16}).attr("flag",false);
			var yesImg = $("<img>").attr("src","../resources/images/ok.png").attr({"width":16,height:16}).attr("flag",true);
			var actionDiv = scope.content.find("div[actionId="+actionId+"]");
			actionDiv.find(".control-label").children().remove();
			actionDiv.find(".control-label").append(noImg);
			$.each(parameterIds,function(i,o){
				var paramId = o;
				var paramInput = scope.content.find("input[paramId="+paramId+"]");
				if(paramInput.length > 0 && actionDiv.length > 0){
					paramInput.bind("click",function(){
						//判断结果是否为true
					 	var result = false;
					 	//第一层数组是或的关系
						$.each(controls,function(ii,oo){
							//第二层数组 是与的关系
							$.each(oo,function(k,ooo){
								var parameterId = ooo.parameterId;
								var value = ooo.value;
								//如果不是当前参数
								var otherParamInput = scope.content.find("input[paramId="+parameterId+"][value="+value+"]:checked");
								if(otherParamInput.length > 0 && oo.length == 1){
									//第二层只有1个节点，而且验证结果为true，则结果为true，则跳出循环
									result = true;
									return false;
								} else if(otherParamInput.length == 0 && oo.length > 1){
									//第二层有多个节点，而且验证结果为false，则结果为false，跳出循环
									result = false;
									return false;
								} else if(otherParamInput.length > 0 && oo.length > 1){
									//第二层有多个节点，而且当前验证结果为true，则结果为true，不跳出循环
									result = true;
								}
							});
							if(result){
								return false;
							}
						});
						var imgDiv = actionDiv.find("img");
						if(result){
							if(relaType == 'Y'){	//关联的动作必选
								if(imgDiv.attr("flag") == "false"){
									actionDiv.find("img").attr("src","../resources/images/ok.png").attr("flag",true);
									actionDiv.show();
								}
							} else if(relaType == 'C'){
								if((actionDiv.find("input[type=checkbox]").length) == 0){
									var div = $("<div>").css({"width":16,height:16}).css("float","right");
									var checkBoxLabel = $("<label>").addClass("checkbox");
									var checkBoxInput = $("<input>").attr("type","checkbox");
									checkBoxLabel.append(checkBoxInput);
									div.append(checkBoxLabel);
									actionDiv.find(".control-label").children().remove();
									actionDiv.find(".control-label").append(div);
									actionDiv.show(); 
								}
							}
						} else {
							//取消选中checkbox
							if(relaType == 'Y'){	//关联的动作必选
								if(imgDiv.attr("flag") == "true"){
									actionDiv.find("img").attr("src","../resources/images/error.png").attr("flag",false);
									actionDiv.show();
								}
							} else if(relaType == 'C'){
								if((actionDiv.find("input[type=checkbox]").length) > 0){
									actionDiv.find(".control-label").children().remove();
									actionDiv.find(".control-label").append(noImg);
									actionDiv.show();
								}
							}
						}
					});
				}
			});
		})
	}
	/**
	 * 设置默认事件处理
	 */
	var _setDefaultEvent = function() {
		var unitDivs = scope.content.find(".packContanierUnit");
		$.each(unitDivs, function(i, o) {
			// 设置参与对象栏
			var partInObjectDiv = $(o).find("div[flag=partInObject]");
			var radioDivs = partInObjectDiv.find("input[type=radio]");
			if(radioDivs.length > 0){
				//如果参与对象有defaultValue，即参与对象上有对应S01的控制参数，这边找到对应的值。
				if(partInObjectDiv.attr("defaultValue")){
					var defaultValue = partInObjectDiv.attr("defaultValue");
					var valueRadio = partInObjectDiv.find("input[type=radio][flag="+defaultValue+"]")
					if(valueRadio.length == 1){
						$(valueRadio).attr("checked","checked");
						$(valueRadio).click();
					}
				} else {
					$(radioDivs[0]).attr("checked","checked");
					$(radioDivs[0]).click();
				}
			}
			// 设置控制参数
			var packParamDivs = $(o).find("div[flag=packParams]");
			if (packParamDivs.length > 0) {
				$.each(packParamDivs, function(ii, oo) {
					var radios = $(oo).find('input[type=radio]');
					if (radios.length > 0) {
						var defaultValue = $(oo).attr("defaultValue");
						if (!defaultValue) {
							$(radios[0]).attr("checked", "checked");
							$(radios[0]).click();
						} else {
							for (var j = 0; j < radios.length; j++) {
								var r = radios[j];
								if ($(r).val() == defaultValue) {
									$(r).attr("checked", "checked");
									$(r).click();
									return false;
								}
							}
						}
					}
					var checkBoxs = $(oo).find("input[type=checkbox]");
					if (checkBoxs.length > 0) {
						var defaultvalue = $(oo).attr("defaultValue");
						$.each(checkBoxs, function(ii, oo) {
									var dValues = "|" + defaultvalue + "|";
									var value = $(oo).val();
									if (dValues.indexOf("|" + value + "|") != -1) {
										$(oo).click();
									}
								});
					}
				});
			}
			var feeTypesDivs = $(o).find("div[flag=feeTypes]");
			$.each(feeTypesDivs, function(ii, oo) {
						var radios = $(oo).find('input[type=radio]');
						if (radios.length > 0) {
							var defaultValue = $(oo).attr("defaultValue");
							if (!defaultValue) {
								$(radios[0]).attr("checked", "checked");
								$(radios[0]).click();
							} else {
								for (var j = 0; j < radios.length; j++) {
									var r = radios[j];
									if ($(r).val() == defaultValue) {
										$(r).attr("checked", "checked");
										$(r).click();
										return;
									}
								}
							}
						}
					});
		});
	}

	/**
	 * 判断页面中多选多的是否满足条件
	 */
	var _guideIsMInNRight = function() {
		// 设置控制参数
		var packParamDivs = scope.content.find("div[flag=packParams]");
		var result = true;
		if (packParamDivs.length > 0) {
			$.each(packParamDivs, function(i, o) {
				if ($(o).find("input[type=checkbox]").length > 0) {
					var checkedBoxs = $(o).find("input[type=checkbox]:checked");
					var up = $(o).attr("up");
					var down = $(o).attr("down");
					var length = $(o).find("input[type=checkbox]").length;
					if(checkedBoxs.length < parseInt(up) || checkedBoxs.length > parseInt(down)){
						alert("不满足" + length + "选" + up + "的要求！");
						result = false;
					}
				}
			});
		}
		return result;
	}
	/**
	 * 给确认提交按钮增加事件
	 */
	var _regesiterEventsForSubmit = function() {
		$("#submitBtn").bind("click", function() {
					// 找到页面中多选多的checkbox，判断是否满足条件
					if (!_guideIsMInNRight()) {
						return;
					}
					if(!pack.dataProcess.collectData(scope.content,scope.data)){
						return;
					}
					$(this).dispatchJEvent("packPageChangeEvent", {
								gotoIndex : 3
							});
				});
	}

	var _regesiterEventsForAccNbrSearchPanel = function() {
		$(this).addJEventListener("joinInAccNbrPanel", function(data) {
			var objectNumber = data.objectNumber;
			var accessNumber = data.accessNumber;
			var prodId = data.prodId;
			
			var objectDiv = scope.content.find("div[flag=partInObject][objNumber="+objectNumber+"]");
			var comboBoxDiv = objectDiv.find(".btn-group");
			if (comboBoxDiv.length == 1) {
				var valueButton = comboBoxDiv.find("button:eq(0)");
				valueButton.attr("val", accessNumber);
				valueButton.attr("prodId", prodId);
				valueButton.html(accessNumber);
			} else {
				var cb = new bootstrap.components.ComboBox();
				cb.addData({
					name:accessNumber,
					value:accessNumber,
					attrs:{
						prodId : prodId
					}
				});
				var comboBoxDiv = objectDiv.find("input[flag='N']").parent().parent().next();
				comboBoxDiv.empty();
				cb.show(comboBoxDiv);
			}

		});
	}
	/**
	 * 注册事件
	 */
	var _regesiterEvents = function() {
		// 1.给每个unitDiv中的不需要按钮注册事件，当点击‘不需要’按钮时，则
		_regesiterEventsForNoNeedRadio();
		// 2.给控制参数注册事件。
		_regesiterEventsForControlParam();
		// 3.设置默认事件处理
		_setDefaultEvent();
		// 4.给确认按钮注册事件
		_regesiterEventsForSubmit();
		// 5.给根据号码查询接入产品信息
	//	_regesiterEventsForAccNbrSearchPanel();
	}
	// 重新布局
	var _resizeForEveryDiv = function() {
		var objectDivs = scope.content.find(".packContanierUnit");
		var max = 0;
		var width = window.screen.width;
		for (var i = 0; i < objectDivs.length; i = i + 2) {
			var fo = objectDivs[i];
			var so = objectDivs[i+1];
			if(!so){
				//无需设置高度，但需要设置宽度
				$(fo).css("width",width*0.44);
				if(width*0.44 <= 550){
					$(fo).css("width",width*0.44);
					$(fo).find("div:eq(0)").css("border-right","1px solid #C1C1C1");
				} else {
					$(fo).css("width", 550);
				}
			} else {
				// 需要设置高度，和宽度
				var fHeight = $(fo).height();
				var sHeight = $(so).height();
				max = (fHeight >= sHeight) ? fHeight : sHeight;
				if (max == 0) {
					max = '250px';
				} 
				$(fo).css("height",max);
				$(so).css("height",max);
				$(fo).find("div[flag=contentDiv]").css("height",max-30);
				$(so).find("div[flag=contentDiv]").css("height",max-30);
				if(width*0.44 <= 550){
					$(fo).css("width",width*0.44);
					$(so).css("width",width*0.44);
					$(fo).find("div:eq(0)").css("border-right","1px solid #C1C1C1");
					$(so).find("div:eq(0)").css("border-right","1px solid #C1C1C1");
				} else {
					$(fo).css("width", 550);
					$(so).css("width", 550);
				}
			}
		}
	}
	/**
	 * 渲染
	 */
	var _render = function() {
		// 获得所有客户、产品类参与对象
		var partInObjectArray = _getAllPartInObject();
		_show(partInObjectArray);
		// 获得所有服务类参与对象
		/*
		 * var servObjectArray = _getAllServObject();
		 * _showForServPackage(servObjectArray);
		 */
		scope.display();
	}

	var _afterRender = function() {
		_regesiterEvents();
		setTimeout(function(){
			_resizeForEveryDiv();
		},1000);
	}
	
	/**
	 * 加载数据
	 */
	var _load = function() {
		// 创建服务框架js客户端类来调用服务
		$.ajax({
				type : "POST",
				async: false,
				url : "../json/getPackageDto.action?packageId=" + pack.gPackInfo.packId,
				dataType : "json",
				success : function(data) {
					scope.data = data;
				},
				error : function(errorMsg) {// 发生错误时消息处理
					$.messager.alert('错误信息', '加载出错!', 'error');
				}
		});
	}
	
	this.display = function() {
		if (scope.displayId) {
			$(scope.displayId).append(scope.content);
		}
	}
	var _constructor = function() {
		_load();
		pack.gPackInfo.extralParams = [];
		_render();
		_afterRender();
	}
	_constructor();
}